package demo;

import sun.misc.Unsafe;

import java.lang.reflect.Field;


public class MyUtils {
    private static Unsafe unsafe = null;
    public static Unsafe getUnSafe(){
        try {
            Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
            theUnsafe.setAccessible(true);
            unsafe = (Unsafe)theUnsafe.get(null);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return unsafe;
    }
}
